<?php

use yii\helpers\Html;
use metronic\grid\GridView;
use metronic\widgets\InlineFilterForm;

/* @var $this yii\web\View */
/* @var $searchModel admin\models\BookChapterSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '章节列表';
$this->params['breadcrumbs'][] = ['label' => '书籍管理', 'url' => ['book/index']];
$this->params['breadcrumbs'][] = ['label' => Yii::$app->book->name, 'url' => ['book/index', 'id' => Yii::$app->book->id]];
$this->params['breadcrumbs'][] = $this->title;
?>

<div class="portlet light bordered">
    <div class="portlet-title">
        <div class="caption">
            <span class="caption-subject bold uppercase"><?= Html::encode($this->title) ?></span>
        </div>
        <div class="actions">
            <?= Html::createButton('新增章节', ['create', 'book_id' => Yii::$app->book->id])?>
        </div>
    </div>
    <div class="portlet-body">
        <div class="row">
            <div class="col-md-12">
                <?php $form = InlineFilterForm::begin([]) ?>
                <div style="display: none">
                    <?= $form->field($searchModel, 'book_id')->hiddenInput() ?>
                </div>
                <?= $form->field($searchModel, 'display_order')->dropDownList(['asc' => '升序', 'desc' => '降序']) ?>
                <?= $form->field($searchModel, 'title') ?>
                <?= InlineFilterForm::end() ?>
            </div>
        </div>
        <?= GridView::widget([
            'dataProvider' => $dataProvider,
            'columns' => [
                ['class' => 'yii\grid\SerialColumn'],

                'title',

                'words',

                'display_order',

                'content',

                [
                    'class' => 'metronic\grid\ActionColumn',
                    'template' => '{update} {delete}',
                    'buttons' => [
                        'update' => function ($url, $model) {
                            return Html::updateActionButton(['update', 'book_id' => $model->book_id, 'id' => $model->id]);
                        },
                        'delete' => function ($url, $model) {
                            return Html::deleteActionButton(['delete', 'book_id' => $model->book_id, 'id' => $model->id], '您确定要删除该章节吗？');
                        },
                    ]
                ],
            ],
        ]); ?>
    </div>
</div>
